<div class="Item hr">
    <div class="current">焦点图管理</div>
    <div class="fr"><a href="{:U('add')}" class="btn">添加焦点图</a></div>
</div>
<form>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tab">
        <thead>
            <tr height="25" align="center">
                <td width="4%">选择</td>
                <td width="" style="text-align:left;">焦点图名称</td>
                <td width="10%">标识</td>
                <td width="20%">风格应用名称</td>
                <td width="15%">添加时间</td>
                <td width="10%">操作</td>
            </tr>
        </thead>
        <tbody>
            <volist name="list" id="focus" empty="$empty">
            <tr align="center">
                <td>{:genCheckbox('fid', '', $focus['id'], false, 'fid')}</td>
                <td style="text-align:left;"><a href="{:U('edit', array('id' => $focus['id']))}">{$focus['title']}</a></td>
                <td>{$focus['nid']}</td>
                <td>{$focus['pattern']}</td>
                <td>{:getDateStr($focus['create_time'])}</td>
                <td><a href="{:U('FocusImg/index', array('fid' => $focus['id']))}" class="icon icon-black icon-image" title="图片管理"></a> <a href="{:U('edit', array('id' => $focus['id']))}" class="icon icon-black icon-edit" title="编辑"></a> <a href="javascript:;" class="deleted icon icon-black icon-trash" data-url="{:U('delete')}" data-id="{$focus.id}" data-title="{$focus.title}" title="删除"></a> <a href="{:U('getcode', array('nid' => $focus['nid']))}" class="icon icon-black icon-web" title="预览"></a></td>
            </tr>
            </volist>
        </tbody>
        <tfoot>
        	<tr>
            	<td colspan="8">
                <label><input name="" class="chooseAll" type="checkbox"> 全选</label> <label><input name="" class="unsetAll" type="checkbox"> 反选</label>
                </td>
            </tr>
        </tfoot>
    </table>
</form>

<div class="page">
    {$page}
</div>
<div class="commonBtnArea" >
    <button class="btn" id="deleted" data-url="{:U('delete')}">删除</button>
</div>

<script type="text/javascript">
$(function(){
	clickCheckbox();
	//单个删除
    $(".deleted").click(function(){
        var url = $(this).data("url");
        var id = $(this).data("id");
        var title = $(this).data("title");

        popup.confirm("您确定删除 <b>" + title + "</b> 焦点图？", '温馨提示',function(action){
            if(action == 'ok'){
                $.ajax({
					"url" : url,
					"dataType" : "JSON",
					"type" : "POST",
					"data" : {"fid" : id},
					"success" : function(json){
                    if (json.status) {
                        popup.success(json.info, "删除成功", function(){
							if(json.url){
								window.location.href = json.url;
							}else{
								top.window.location.reload();
							}
						});
                    } else {
                        popup.error(json.info);
                        setTimeout(function(){
                            popup.close("asyncbox_error");
                        },2000);
                    }
                }
				});
            }
        });

        return false;
    });
	//批量删除
    $("#deleted").click(function(){
        var url = $(this).data("url");
		var isDeleted = false;
		var fids = [];
		$(".fid").each(function(){
			if($(this).prop("checked")){
				isDeleted = true;
				fids.push($(this).val());
			}
		})
		if(isDeleted){
			popup.confirm("您确定批量删除文档？", '温馨提示',function(action){
				if(action == 'ok'){
					$.ajax({
						"url" : url,
						"dataType" : "JSON",
						"type" : "POST",
						"data" : {"fids" : fids, "act" : "two"},
						"success" : function(json){
						if (json.status) {
							popup.success(json.info, "删除成功", function(){
								if(json.url){
									window.location.href = json.url;
								}else{
									top.window.location.reload();
								}
							});
						} else {
							popup.error(json.info);
							setTimeout(function(){
								popup.close("asyncbox_error");
							},2000);
						}
					}
					});
				}
			});
		}
        return false;
    });
});
</script>